local sk__jieyan = fk.CreateSkill {

  name = "sk__jieyan",

  tags = {},

}



sk__jieyan:addEffect(fk.TargetSpecified, {
  name = "sk__jieyan",
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__jieyan.name) and (data.card.trueName == "slash" or data.card.type == Card.TypeTrick) and
        data.card.color == Card.Red and #data:getAllTargets() == 1 and not player:isKongcheng() and
        not data.to.dead
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, false, sk__jieyan.name, true, ".",
      "#sk__jieyan-invoke::" .. data.to.id .. ":" .. data.card:toLogString(), true)
    if #card > 0 then
      event:setCostData(self, card)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = data.to
    room:doIndicate(player.id, { data.to })
    room:throwCard(event:getCostData(self), sk__jieyan.name, player, player)
    data:cancelTarget(to)
    if not to.dead then
      room:damage {
        from = player,
        to = to,
        damage = 1,
        damageType = fk.FireDamage,
        skillName = sk__jieyan.name,
      }
    end
  end,
})

return sk__jieyan
